Skip to content

Conversation

@najuna-brian
Copy link
Contributor

Description

Fixes handlebars template syntax in labels that was not being expanded. Labels with syntax like {{data.fieldName}} now properly replace placeholders with actual form data values.

Context

This PR replaces #258 , which failed CI due to the branch not being found in the upstream repository. The branch has now been pushed to the upstream repository to resolve the CI checkout issue.

Changes

  • Added handlebars template processing in HtmlLabelRenderer.tsx
  • Uses useJsonForms() hook to access form data reactively
  • Processes {{data.fieldName}} syntax to replace with actual values
  • Handles missing values gracefully (replaces with empty string)
  • Maintains backward compatibility with labels without handlebars syntax

Technical Details

  • Detects handlebars syntax pattern: {{data.fieldName}}
  • Extracts field name and looks up value in form data object
  • Updates reactively when form data changes
  • Works with ODE's flat data structure (no data wrapper needed)

Testing

✅ Tested on phone with p_wealth_new form - handlebars templates now expand correctly

  • Verified with pre-filled data: placeholders replaced with actual values
  • Verified with missing data: placeholders replaced with empty strings
  • Verified reactive updates: labels update when form fields change

Related Issue

Fixes

Migration Notes

Forms converted from OMO/ODK-X format that use {{data.fieldName}} syntax in labels will now work correctly in ODE Formplayer without any changes needed.

@najuna-brian
Copy link
Contributor Author

I pushed this PR to the upstream after the one i opened through the fork failed.
@Bahati308 May be we need to look at the error on the othr similar PR I opened first? for "branch not found...."

But after I opened this PR, the checks on the first PR passed

@Mishael-2584
Copy link
Contributor

Mishael-2584 commented Jan 27, 2026

Could we have this PR in @najuna-brian

@Mishael-2584 Mishael-2584 merged commit 27b6a0f into dev Jan 27, 2026
10 checks passed
@najuna-brian najuna-brian deleted the fix/handlebars-template-labels branch January 28, 2026 15:40
@najuna-brian
Copy link
Contributor Author

Thanks @Mishael-2584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants